/**
 * Created by likai on 16/3/24.
 */
var url = 'https://'+location.host+location.pathname;
baseurl = url.substring(0,url.lastIndexOf('/')+1);
$.ajax({
    'url':'//app.kekeshi.com/xq/auth/index.php',
    'data':{'url':location.href.split('#')[0]},
    'dataType':'jsonp',
    success:function(json){
        console.log(json)
        var wxConfig = {
            debug:false,
            appId: json['appId'],
            timestamp: json['timestamp'],
            nonceStr: json['nonceStr'],
            signature: json['signature'],
            jsApiList: [
                "onMenuShareTimeline",
                "onMenuShareAppMessage",
                "chooseImage",
                "uploadImage",
                "getLocalImgData"
            ]
        }
        wx.config(wxConfig);

    }

});

var wxData = {
    imgUrl: 'https://app.kekeshi.com/xq/kksfx/share.png',
    link: url,
    title: '可可狮，分月家庭早教t',
    desc: '可可狮，分月家庭早教',
    qtitle: '可可狮，分月家庭早教',
    share:function(){
        //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
        wx.onMenuShareTimeline({
            title: wxData.qtitle,
            link: wxData.link,			
            imgUrl: wxData.imgUrl,
            success: function() {
                wxData.success('timeline');
                wxData.callback();
            },
            cancel: function() {

            }
        });

        //获取“分享给朋友”按钮点击状态及自定义分享内容接口
        wx.onMenuShareAppMessage({
            title: wxData.title,
            desc: wxData.desc,
            link: wxData.link,
            imgUrl: wxData.imgUrl,
            type: '', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function() {
                wxData.success('appmessage');
                wxData.callback();
            },
            cancel: function() {

            }
        });
    },
    success:function(type){

    },
    callback:function(){

    }
};

wx.ready(function() {
	wxData.share();
	var u = navigator.userAgent;
	var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
	if(!isAndroid) {
		// window.player = document.getElementById("video1");;
		// window.player.play();
		// window.player.pause()
	} else {
		
	}
});
wx.error(function(res) {
    //alert(JSON.stringify(res));
});
wxData.success = function(type){
    //_hmt.push(['_trackEvent', 'share', type]);
};